<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/10/26
  Time: 13:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/include/taglib.jsp" %>
<% String sellerName = request.getSession().getAttribute("sellerName") + "";%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title class="languageToggle">Website Back End</title>
    <%@ include file="/include/easyui.jsp" %>
    <style>
        #verify {
            border-spacing: 10px;
        }

        #toolbarTable td {
            padding-left: 15px
        }
        .pagination{
            position: relative;
            top:-30px;
        }
    </style>
</head>
<body>
<div style="width:100%;height:30px;background-color:#F2F2F2;float:left">
    <table id="toolbarTable">
        <tr>
            <td><span class="languageToggle">Welcome</span>:<%=sellerName%>
            </td>
            <td>ID:${param.id}</td>
            <td><a href="#" onclick="changePassword()"><span class="languageToggle">Change password</span></a></td>
            <td><a href="${ctx}/mulanweb/common/login_out/sellerLogout"><span class="languageToggle">Log out</span></a>
            </td>
            <td><a href="#" id="toggleLanguage"><span class="languageToggle">Chinese</span></a></td>
        </tr>
    </table>
</div>
<div class="easyui-tabs" style="padding:0px;margin:0px;height:80%" fit="true" border="false" noheader="true">
    <div title="verification page" style="padding:10px">
        <table id="verify">
            <tr>
                <td><span class="languageToggle">verification type</span>：</td>
                <td><select class="easyui-combobox" id="verifyType" style="width:240px">
                </select></td>
            </tr>
            <tr>
                <td><span class="languageToggle">verification code</span>：</td>
                <td><input class="easyui-textbox" id="verifyCode" style="width:240px"/></td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center">
                    <button type="button" id="verifyButton" style="width:220px">
                        <span class="languageToggle">Submit</span></button>
                </td>
            </tr>
        </table>
    </div>
    <div title="My Services">
        <div id="datagrid"></div>
    </div>
    <div title="My Order">
        <div id="datagrid-order"></div>
    </div>
</div>
<div id="toolbar">
    <select id="typeId" class="easyui-combobox" style="width:100px"></select>
    <a id="updateSeller" href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'">
        <span class="languageToggle">change</span></a>
</div>
<div id="dialog"></div>
<div id="changePassword" class="easyui-dialog" style="padding: 10px 20px">
    <table>
        <tr>
            <td><span class="languageToggle">Original Password</span>：</td>
            <td><input type="password" id="old-password" class="easyui-validatebox " data-options="required:true"/></td>
        </tr>
        <tr>
            <td><span class="languageToggle">New Password</span>：</td>
            <td><input type="password" id="new-password-1" class="easyui-validatebox "
                       data-options="required:true,missingMessage:'必填，两次密码需一致'"/></td>
        </tr>
        <tr>
            <td><span class="languageToggle">New Password</span>：</td>
            <td><input type="password" id="new-password-2" class="easyui-validatebox "
                       data-options="required:true,missingMessage:'必填，两次密码需一致'"/></td>
        </tr>
    </table>
</div>
<script type="text/javascript">
    var language = 2;//第一次切换的语言，2为中文
    var content = {
        label1: 'Tickets',
        label2: 'private tours by chartered car',
        operationType1: 'available',
        operationType2: 'not available',
        changePasswordTitle: 'Change Passowrd',
    }
    $(document).ready(function () {
        var $datagrid = $("#datagrid"), $toolbar = $("#toolbar"), $dialog = $("#dialog"), $orderDatagrid = $("#datagrid-order");

        $(".easyui-tabs").tabs({
            onSelect:function(title,index){
                if(index == 2){
                    $orderDatagrid.datagrid({
                        singleSelect: true,
                        fit: true,
                        border: false,
                        fitColumns: true,
                        url: Constant.ctx("/mulanweb/seller/content/getOrder"),
                        method: 'post',
                        pagination: true,
                        columns: [[
                            {field: 'id', title: 'Number'},
                            {field: 'orderNumber', title: 'OrderNumber'},
                            {field: 'title', title: 'Title',formatter:function(v,r,i){
                                return r.target.titleEn;
                            }},
                            {field: 'price', title: 'Price',formatter:function(v,r,i){
                                return "$"+r.target.nzdPrice;
                            }},
                            {field: 'amount', title: 'Quantity'},
                            {field: 'mobileNumber', title: 'Tel'},
                            {field: 'remark', title: 'Remark'},
                            {field: 'statusId', title: 'Status', formatter: function (v, r, i) {
                                if (v == 4) {
                                    return 'Have Paid';
                                }else if(v ==5) {
                                    return 'Haven\'t Paid';
                                }else if (v == 6) {
                                    return 'Expired';
                                }  else if (v == 7) {
                                    return 'Verified';
                                }else if (v == 8) {
                                    return 'Commented';
                                }else if(v==9){
                                    return 'Refunded';
                                }else{
                                    return v;
                                }
                            }},
                            {field: 'createTime', title: 'Creation Time'},
                        ]],
                        onBeforeLoad: function (param) {
                            param.PageNumber = param.page;
                            param.PageSize = param.rows;
                            param.typeId = $("#typeId").combobox("getValue");
                            return true;
                        },
                        loadFilter: function (data) {

                            return data;
                        }
                    });
                }
            }
        });

        var rowIndex;
        $("#changePassword").dialog('close');
        $("#verifyButton").on("click", submit);
        $.extend($.fn.datagrid.methods, {
            editCell: function (jq, param) {
                return jq.each(function () {
                    var opts = $(this).datagrid('options');
                    var fields = $(this).datagrid('getColumnFields', true).concat($(this).datagrid('getColumnFields'));
                    for (var i = 0; i < fields.length; i++) {
                        var col = $(this).datagrid('getColumnOption', fields[i]);
                        col.editor1 = col.editor;
                        if (fields[i] != param.field) {
                            col.editor = null;
                        }
                    }
                    $(this).datagrid('beginEdit', param.index);
                    for (var i = 0; i < fields.length; i++) {
                        var col = $(this).datagrid('getColumnOption', fields[i]);
                        col.editor = col.editor1;
                    }
                });
            }
        });
        function endEdit() {
            if ($datagrid.datagrid('validateRow', rowIndex)) {
                $datagrid.datagrid('endEdit', rowIndex);
            }
        }

        $("#updateSeller").on("click", function () {
            var selectRows = $datagrid.datagrid("getSelected");
            if (selectRows) {
                var typeId = $("#typeId").combo("getValue");
                if (typeId == 23) {
                    $datagrid.datagrid('editCell', {index: rowIndex, field: 'SurplusTotal'});
                    $(".validatebox-text").on("blur", function () {
                        $(".validatebox-text").unbind("blur");
                        endEdit();
                    });
                    $(".validatebox-text").on("keydown", function (ev) {
                        if (ev.keyCode == 13) {
                            $(".validatebox-text").unbind("blur");
                            $(".validatebox-text").unbind("keydown");
                            endEdit();
                        }
                    });
                } else if (typeId == 24) {
                    var startTime = selectRows.startTime.split(" ")[1];
                    var endTime = selectRows.endTime.split(" ")[1];
                    var weekWork = selectRows.weekWork;
                    var targetId = selectRows.id;
                    openDialog(startTime, endTime, weekWork, targetId);
                }
            } else {
                var title = '';
                var alertContent = '';
                if (language == 2) {
                    title = "Tips";
                    alertContent = "Please select a target";
                } else {
                    title = "提示";
                    alertContent = "请选择目标";
                }
                $.messager.show({
                    title: title,
                    msg: alertContent,
                    showType: 'slide',
                    style: {
                        right: '',
                        top: document.body.scrollTop + document.documentElement.scrollTop,
                        bottom: ''
                    },
                    timeout: 3000
                });
            }
        });
        var rows = [[
            {field: 'Id', title: 'Number'},
            {field: 'TitleEn', title: 'Title'},
            {field: 'NzdPrice', title: 'Price',formatter:function(v,r,i){
                return "$"+v;
            }},
            {field: 'SurplusTotal', title: 'Remaining Quantity', editor: {type: 'numberbox', options: {precision: 0}}},
            {field: 'Total', title: 'Total Quantity'},
            {
                field: 'TypeId', title: 'Type', formatter: function (v, r, i) {
                if (v == 1) {
                    return 'Ticket';
                } else if (v == 2) {
                    return 'Shopping Coupon';
                } else if (v == 3) {
                    return 'Catering Coupon';
                }
            }
            },
            {field: 'CreateTime', title: 'Issue Time'},
            {
                field: 'NotAvailableTime', title: 'Operation ', formatter: function (v, r, i) {
                if (v) {
                    return '<a href="#" onclick="updateStatus(' + r.Id + ')">available</a>';
                } else {
                    return '<a href="#" onclick="updateStatus(' + r.Id + ')">not available</a>';
                }
            }
            }
        ]];//En 门票券票
        $("#verifyType").combobox({
            valueField: 'value',
            textField: 'label',
            data: [{
                label: content.label1,
                value: '23'
            }, {
                label: content.label2,
                value: '24'
            }]
        }).combobox("setValues", "23");
        $("#typeId").combobox({
            valueField: 'value',
            textField: 'label',
            data: [{
                label: content.label1,
                value: '23'
            }, {
                label: content.label2,
                value: '24'
            }],
            onChange: function (newV, oldV) {
                if (oldV) {
                    if (language == 1) {
                        language = 2;
                    } else {
                        language = 1;
                    }
                    toggleLanguage();
                    //$datagrid.datagrid({columns:cols});
                }
            }
        }).combobox("setValues", "23");
        $datagrid.datagrid({
            singleSelect: true,
            fit: true,
            border: false,
            fitColumns: true,
            url: Constant.ctx("/mulanweb/seller/content/search"),
            method: 'post',
            pagination: true,
            toolbar: $toolbar,
            columns: rows,
            onClickRow: function (index, row) {
                rowIndex = index;
            },
            onEndEdit: function (index, rows, value) {
                var para = {
                    targetId: rows.Id,
                    amount: value.SurplusTotal
                }
                $.post(Constant.ctx("/mulanweb/seller/content/updateTicket"), para, function (info) {
                    if (info.ReturnCode == 1) {
                        Constant.showMessage(info.AlertMessage, info.message, "验证成功")
                    } else {
                        Constant.showMessage(info.AlertMessage, info.message, "验证失败")
                    }
                    $datagrid.datagrid("reload");
                });
            },
            onBeforeLoad: function (param) {
                param.PageNumber = param.page;
                param.PageSize = param.rows;
                param.typeId = $("#typeId").combobox("getValue");
                return true;
            },
            loadFilter: function (data) {
                var newData = {};
                var rows = [];
                if (data.ReturnCode == 1) {
                    for (var i in data.DataList) {
                        var row = {}
                        var weekWork = data.DataList[i].weekWork;
                        if (weekWork) {
                            for (var ii in data.DataList[i].target) {
                                row[ii] = data.DataList[i].target[ii];
                            }
                            row["weekWork"] = weekWork;
                        } else {
                            row = data.DataList[i];
                        }
                        rows[i] = row;
                    }
                    newData.rows = rows;
                    if (newData.rows.length > 0) {
                        newData.total = data.TotalRow;
                    } else {
                        newData.total = 0;
                    }
                }
                return newData;
            }
        });
        function openDialog(startTime, endTime, weekWork, targetId) {
            var url = "chartered_form.jsp";
            var typeId = $("#typeId").combobox("getValue");
            if (typeId == 23) {
                url = "ticket_form.jsp";
            }
            url = url + "?startTime=" + startTime + "&endTime=" + endTime + "&weekWork=" + weekWork + "&targetId=" + targetId + "&language=" + language;
            var title = "";
            var edit = "";
            if (language == 1) {
                title = "修改内容";
                edit = "修改";
            } else {
                title = "Edit Content";
                edit = "Update";
            }
            $dialog.dialog({
                title: title,
                width: 400,
                height: 300,
                closed: false,
                cache: false,
                href: url,
                modal: true,
                onClose: function () {
                    $("#form-dialog").dialog("destroy");
                },
                buttons: [{
                    text: edit,
                    handler: saveAccount
                }]
            });
        }

        function saveAccount() {
            $("form").form("submit", {
                url: $("form").attr("action"),
                onSubmit: function () {
                    var isValid = $(this).form('validate');
                    if (!isValid) {
                        $.messager.progress('close');	// hide progress bar while the form is invalid
                    }
                    return isValid;
                },
                success: function (respText) {
                    var resp = $.parseJSON(respText);
                    Constant.showMessage(resp.AlertMessage, resp.message, "操作完成");
                    if (resp.ReturnCode == 1) {
                        $("#datagrid").datagrid("reload");
                        $dialog.dialog("close");
                    }
                }
            });
        }

        $("#toggleLanguage").on("click", toggleLanguage);
        function setEnglish(string) {
            var result = string;
            result = result.replace("新西兰商户后台", "Website Back End");
            result = result.replace('工作星期数', 'Working Weeks ');
            result = result.replace("餐饮优惠券", "Catering Coupon");
            result = result.replace("购物优惠券", "Shopping Coupon");
            result = result.replace('工作时间', 'Working Schedule');
            result = result.replace('修改密码', 'Change password');
            result = result.replace('退出登陆', 'Log out');
            result = result.replace('验证类型', 'verification type');
            result = result.replace('门票券票', 'Tickets');
            result = result.replace('包车陪游', 'private tours by chartered car');
            result = result.replace('我的内容', 'My Services');
            result = result.replace('我的订单', 'My Order');
            result = result.replace('发布时间', 'Issue Time');
            result = result.replace('剩余数量', 'Remaining Quantity');
            result = result.replace('欢迎您', 'Welcome');
            result = result.replace('验证页', 'verification page');
            result = result.replace('验证码', 'verification code');
            result = result.replace('总数量', 'Total Quantity');
            result = result.replace('原密码', 'Original Password');
            result = result.replace('新密码', 'New Password');
            result = result.replace('编号', 'Number');
            result = result.replace('标题', 'Title');
            result = result.replace('单价', 'Price');
            result = result.replace('操作', 'Operation');
            result = result.replace('车牌', 'Plate Number');
            result = result.replace('提交', 'Submit');
            result = result.replace('类型', 'Type');
            result = result.replace("修改", "change");
            result = result.replace("英文", "Chinese");
            result = result.replace("下架", "Not Available");
            result = result.replace("上架", "Available");
            result = result.replace("门票", "Ticket");
            return result;
        }

        function setChinese(string) {
            var result = string;
            result = result.replace('private tours by chartered car', '包车陪游');
            result = result.replace('Remaining Quantity', '剩余数量');
            result = result.replace('verification page', '验证页');
            result = result.replace('verification type', '验证类型');
            result = result.replace('verification code', '验证码');
            result = result.replace('Original Password', '原密码');
            result = result.replace('Working Schedule', '工作时间');
            result = result.replace("Website Back End", "新西兰商户后台");
            result = result.replace('Change password', '修改密码');
            result = result.replace("Catering Coupon", "餐饮优惠券");
            result = result.replace("Shopping Coupon", "购物优惠券");
            result = result.replace('Total Quantity', '总数量');
            result = result.replace("Not Available", "下架");
            result = result.replace('Working Weeks ', '工作星期数');
            result = result.replace('Plate Number', '车牌');
            result = result.replace('New Password', '新密码');
            result = result.replace('My Services', '我的内容');
            result = result.replace('Issue Time', '发布时间');
            result = result.replace('Operation', '操作');
            result = result.replace("Available", "上架");
            result = result.replace('My Order', '我的订单');
            result = result.replace('Welcome', '欢迎您');
            result = result.replace('Log out', '退出登陆');
            result = result.replace('Tickets', '门票券票');
            result = result.replace('Ticket', '门票');
            result = result.replace("Chinese", "英文");
            result = result.replace('Number', '编号');
            result = result.replace('Submit', '提交');
            result = result.replace("change", "修改");
            result = result.replace('Title', '标题');
            result = result.replace('Price', '单价');
            result = result.replace('Type', '类型');
            return result;
        }

        var cols = [];

        function toggleLanguage(tags) {
            var result = (language == 1);
            if (result) {
                content.operationType1 = 'available';
                content.operationType2 = 'not available';
                content.ticket1 = "Ticket";
                content.ticket2 = "Catering Coupon";
                content.ticket3 = "Shopping Coupon";
                content.title = "TitleEn";
                content.priceTag = "$";
                content.price = "NzdPrice";
                var orderCols = [[
                        {field: 'id', title: 'Number'},
                        {field: 'orderNumber', title: 'OrderNumber'},
                        {field: 'title', title: 'Title',formatter:function(v,r,i){
                            return r.target.titleEn;
                        }},
                        {field: 'price', title: 'Price',formatter:function(v,r,i){
                            return "$"+r.target.nzdPrice;
                        }},
                        {field: 'amount', title: 'Quantity'},
                        {field: 'mobileNumber', title: 'Tel'},
                        {field: 'remark', title: 'Remark'},
                        {field: 'statusId', title: 'Status', formatter: function (v, r, i) {
                            if (v == 4) {
                                return 'Have Paid';
                            }else if(v ==5) {
                                return 'Haven\'t Paid';
                            }else if (v == 6) {
                                return 'Expired';
                            }  else if (v == 7) {
                                return 'Verified';
                            }else if (v == 8) {
                                return 'Commented';
                            }else if(v==9){
                                return 'Refunded';
                            }else{
                                return v;
                            }
                        }},
                        {field: 'createTime', title: 'Creation Time'},
                ]]
                $orderDatagrid.datagrid({
                    columns: orderCols
                })
            } else {
                content.operationType1 = '上架';
                content.operationType2 = '下架';
                content.ticket1 = "门票";
                content.ticket2 = "餐饮优惠券";
                content.ticket3 = "购物优惠券";
                content.title = "Title";
                content.priceTag = "￥";
                content.price = "Price";
                var orderCols = [[
                    {field: 'id', title: '编号'},
                    {field: 'orderNumber', title: '订单号'},
                    {field: 'title', title: '商品名',formatter:function(v,r,i){
                        return r.target.title;
                    }},
                    {field: 'price', title: '单价',formatter:function(v,r,i){
                        return "￥"+r.target.price;
                    }},
                    {field: 'amount', title: '数量'},
                    {field: 'mobileNumber', title: '电话'},
                    {field: 'remark', title: '备注'},
                    {field: 'statusId', title: '状态', formatter: function (v, r, i) {
                        if (v == 4) {
                            return '已支付';
                        }else if(v ==5) {
                            return '未支付';
                        }else if (v == 6) {
                            return '已过期';
                        }  else if (v == 7) {
                            return '已验证';
                        }else if (v == 8) {
                            return '已评论';
                        }else if(v==9){
                            return '已退款';
                        }else{
                            return v;
                        }
                    }},
                    {field: 'createTime', title: '创建时间'},
                ]]
                $orderDatagrid.datagrid({
                    columns: orderCols
                })
            }
            var typeId = $("#typeId").combobox("getValue");
            if (typeId == 24) {
                cols = [[
                    {field: 'id', title: '编号'},
                    {field: content.title, title: '标题'},
                    {
                        field: content.price, title: '单价', formatter: function (v, r, i) {
                        return content.priceTag + v;
                    }
                    },
                    {field: 'plateNumber', title: '车牌'},
                    {
                        field: 'startTime', title: '工作时间', formatter: function (v, r, i) {
                        var startTime = v.split(" ");
                        var endTime = r.endTime.split(" ");
                        return startTime[1] + "-" + endTime[1];
                    }
                    },
                    {field: 'weekWork', title: '工作星期数'},
                    {field: 'createTime', title: '发布时间'},
                    {
                        field: 'NotAvailableTime', title: '操作', formatter: function (v, r, i) {
                        if (v) {
                            return '<a href="#" onclick="updateStatus(' + r.id + ')">' + content.operationType1 + '</a>';
                        } else {
                            return '<a href="#" onclick="updateStatus(' + r.id + ')">' + content.operationType2 + '</a>';
                        }
                    }
                    }
                ]]
            } else {
                cols = [[
                    {field: 'Id', title: '编号'},
                    {field: content.title, title: '标题'},
                    {field: content.price, title: '单价', formatter: function (v, r, i) {
                        return content.priceTag + v;
                    }
                    },
                    {field: 'SurplusTotal', title: '剩余数量', editor: {type: 'numberbox', options: {precision: 0}}},
                    {field: 'Total', title: '总数量'},
                    {
                        field: 'TypeId', title: '类型', formatter: function (v, r, i) {
                        console.info(v);
                        if (v == 1) {
                            return content.ticket1;
                        } else if (v == 2) {
                            return content.ticket2;
                        } else if (v == 3) {
                            return content.ticket3;
                        }
                    }
                    },
                    {field: 'CreateTime', title: '发布时间'},
                    {
                        field: 'NotAvailableTime', title: '操作', formatter: function (v, r, i) {
                        if (v) {
                            return '<a href="#" onclick="updateStatus(' + r.id + ')">' + content.operationType1 + '</a>';
                        } else {
                            return '<a href="#" onclick="updateStatus(' + r.id + ')">' + content.operationType2 + '</a>';
                        }
                    }
                    }
                ]]
            }
            if (result) {
                for (var i in cols[0]) {
                    for (var t in cols[0][i]) {
                        if (t == "title") {
                            cols[0][i][t] = setEnglish(cols[0][i][t]);
                        }
                    }
                }
            } else if (language == 2) {
                for (var i in cols[0]) {
                    for (var t in cols[0][i]) {
                        if (t == "title") {
                            cols[0][i][t] = setChinese(cols[0][i][t]);
                        }
                    }
                }
            }
            if (!tags) {
                $("#datagrid").datagrid({
                    columns: cols
                })
                if (language == 1) {
                    language = 2;
                } else {
                    language = 1;
                }
                return;
            }
            $("#datagrid").datagrid({
                columns: cols
            });
            if (language == 1) {
                var length = $(".languageToggle").length;
                var r = 0;
                while (r < length) {
                    var text = ".languageToggle:eq(" + r + ")";
                    var cn = $(text).text();
                    var en = setEnglish(cn);
                    if (en && en != text) {
                        $(text).text(en);
                    }
                    r++;
                }

                var tabLength = $(".tabs-title").length;
                var i = 0;
                while (i < tabLength) {
                    var text = ".tabs-title:eq(" + i + ")";
                    var cn = $(text).text();
                    var en = setEnglish(cn);
                    if (en && en != text) {
                        $(text).text(en);
                    }
                    i++;
                }

                content.label1 = 'Tickets';
                content.label2 = 'private tours by chartered car';
                content.changePasswordTitle = "Change Password";
                $('#verifyType').combobox('loadData', [{
                    label: content.label1,
                    value: '23'
                }, {
                    label: content.label2,
                    value: '24'
                }]);
                $('#typeId').combobox('loadData', [{
                    label: content.label1,
                    value: '23'
                }, {
                    label: content.label2,
                    value: '24'
                }]);
                language = 2;
            } else if (language == 2) {
                var length = $(".languageToggle").length;
                var r = 0;
                while (r < length) {
                    var text = ".languageToggle:eq(" + r + ")";
                    var cn = $(text).text();
                    var en = setChinese(cn);
                    if (en && en != text) {
                        $(text).text(en);
                    }
                    r++;
                }

                var tabLength = $(".tabs-title").length;
                var i = 0;
                while (i < tabLength) {
                    var text = ".tabs-title:eq(" + i + ")";
                    var cn = $(text).text();
                    var en = setChinese(cn);
                    if (en && en != text) {
                        $(text).text(en);
                    }
                    i++;
                }
                content.label1 = '门票券票';
                content.label2 = '包车陪游';
                content.changePasswordTitle = "修改密码";
                $('#verifyType').combobox('loadData', [{
                    label: content.label1,
                    value: '23'
                }, {
                    label: content.label2,
                    value: '24'
                }]);
                $('#typeId').combobox('loadData', [{
                    label: content.label1,
                    value: '23'
                }, {
                    label: content.label2,
                    value: '24'
                }]);
                language = 1;
            }
        }
    });

    //上下架
    function updateStatus(id) {
        if (id) {
            var typeId = $("#typeId").combobox("getValue");
            var para = {
                targetId: id,
                typeId: typeId
            }
            $.post(Constant.ctx("/mulanweb/seller/content/updateStatus"), para, function (info) {
                var success = "操作成功";
                var fail = '操作失败';
                if (language == 1) {
                    success = setEnglish(success);
                    fail = setEnglish(fail);
                }
                if (info.ReturnCode == 1) {
                    Constant.showMessage(info.AlertMessage, success);
                    $("#datagrid").datagrid("reload");
                } else {
                    Constant.showMessage(info.AlertMessage, fail);
                }
            })
        } else {

        }
    }
    //提交认证
    function submit() {
        var verifyCode = $("#verifyCode").val();
        var verifyType = $("#verifyType").combobox("getValue");
        var para = {
            verifyCode: verifyCode,
            typeId: verifyType
        }
        $.post(Constant.ctx("/mulanweb/seller/verify/codeVerify"), para, function (info) {
            if (info.ReturnCode == 1) {
                $("#verifyCode").val("");
                Constant.showMessage(info.AlertMessage, info.message, "Verify the success")
            } else {
                Constant.showMessage(info.AlertMessage, info.message, "Validation failure")
            }
        });

    }
    //修改密码
    function changePassword() {
        $("#changePassword").dialog({
            title: content.changePasswordTitle,
            width: 350,
            height: 250,
            cache: false,
            buttons: [{
                text: 'ok',
                iconCls: 'icon-ok',
                handler: function () {
                    var new_password_1 = $("#new-password-1").val();
                    var new_password_2 = $("#new-password-2").val();
                    var old_password = $("#old-password").val();
                    if (new_password_1 && new_password_2 && new_password_1 == new_password_2) {
                        var data = {
                            oldPassword: old_password,
                            newPassword: new_password_1
                        };
                        $.post(Constant.contextUrl + "/mulanweb/admin/seller/updatePassword", data, function (info) {
                            if (info.ReturnCode == 1) {
                                $.messager.confirm("提示", "操作成功，请重新登录", function (r) {
                                    location.href = "${ctx}/admin/common/admin_user/sellerLogout";
                                });
                            } else if (info.ReturnCode == 0) {
                                Constant.showMessage("原密码错误");
                            }
                        })
                    } else {
                        Constant.showMessage("两次密码不一致");
                    }
                }
            }, {
                text: 'cancel',
                iconCls: 'icon-cancel',
                handler: function () {
                    $("#changePassword").dialog("close");
                }
            }]
        });
        $("#changePassword").dialog('center');
        $("#changePassword").dialog('open');
    }
</script>
</body>
</html>
